package com.dsteiner.gwt.cafeteriasophia.client;


import com.dsteiner.gwt.cafeteriasophia.client.ChangesWidget.ChangesModel;
import com.dsteiner.gwt.cafeteriasophia.client.controller.ShiftChangeController;
import com.dsteiner.gwt.cafeteriasophia.client.domain.Product;
import com.dsteiner.gwt.cafeteriasophia.client.model.NavModel;
import com.dsteiner.gwt.cafeteriasophia.client.model.ProductModel;
import com.dsteiner.gwt.cafeteriasophia.client.model.ShiftChangeModel;
import com.dsteiner.widgets.client.PrefilledTextBox;
import com.dsteiner.widgets.client.Widgets.ButtonExt;
import com.dsteiner.widgets.client.Widgets.HTMLExt;
import com.dsteiner.widgets.client.Widgets.LazyWidget;
import com.dsteiner.widgets.client.event.EventManagerImpl;
import com.dsteiner.widgets.client.model.PrefilledTextBoxModel;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.IncrementalCommand;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;

public class ShiftChangeWidget extends LazyWidget {

	private ShiftChangeController shiftChangeController = new ShiftChangeController();
	private final ShiftChangeModel shiftChangeModel;

	public ShiftChangeWidget(ShiftChangeModel shiftChangeModel) {
		this.shiftChangeModel = shiftChangeModel;
		setStyleName("shift-change-widget");
	}

	@Override
	public Widget createContentWidget() {
		FlowPanel mainPanel = new FlowPanel();
		HTMLExt navLink = new HTMLExt("<a href=\"javascript:void(0);\">regresar al menu</a>");
		ButtonExt saveButton = new ButtonExt("ingresar datos del cambio de turno ahora");
		HTMLExt titleHtml = new HTMLExt();
		ChangesModel changesModel = new ChangesModel();
		ChangesWidget changesWidget = new ChangesWidget(changesModel);
		ShiftChangeEditWidget shiftChangeEditWidget = new ShiftChangeEditWidget(shiftChangeModel);
		
		mainPanel.add(navLink);
		mainPanel.add(titleHtml);
		mainPanel.add(shiftChangeEditWidget);
		mainPanel.add(saveButton);

		titleHtml.addStyleName("title-html");
		
		shiftChangeController.registerNavLink(navLink);
		shiftChangeController.registerTitleHtml(titleHtml);
		shiftChangeController.registerShiftChangeWidget(this);
		shiftChangeController.registerShiftChangeModel(shiftChangeModel);
		shiftChangeController.registerSaveButton(saveButton);
		shiftChangeController.registerEventManager(EventManagerImpl.getInstance());
		return mainPanel;
	}

}